﻿<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class SettingModel extends BaseModel
{

    var $table  = 'settings';	

	
    /* 插入数据 */
    function post($key ='',$value = '')
    {   
			  
		return $this->IU_Sql_Exe(array ('data' => array('keyname'=>"$key",'value'=>"$value",'lang_type'=>trim($GLOBALS['Lang']->_lang_tp)), 'mode' => 'INSERT'));

        
    }


    /* 插入数据 */
    function replace($keyname ='',$valuename = '',$data=array())
    {   
		
		$str = '';		
		foreach($data as $key => $value)
		{ 
		   $str .= "('$key','$value','".trim($GLOBALS['Lang']->_lang_tp)."'),";	   
		              
		}
		$str = substr($str,0,-1);
		return $this->db->query("replace into {$this->table} ({$keyname},{$valuename},lang_type) values $str ;");
        
    }

    function show()
    {   
	
		 $info = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"lang_type='".trim($GLOBALS['Lang']->_lang_tp)."' or lang_type='' "));
    
		 return $info;
        
    }
    function allshow()
    {   
	
		 $info = $this->S_Sql_Exe(array('fields' =>'*'));
    
		 return $info;
        
    }


    /* 修改数据 */
    function editaction($key ='',$value = '')
    {    
 	      
		return $this->IU_Sql_Exe(array ('data' => array('value'=>"$value"),'mode' => 'UPDATE','conditions' =>"keyname = '{$key}' and lang_type='".trim($GLOBALS['Lang']->_lang_tp)."' "));
        
    }


    /* 通过id取出一条数据 */
    function oneshow($key ='')
    {    
	      
		 $info = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"keyname='{$key}' and lang_type='".trim($GLOBALS['Lang']->_lang_tp)."' ",'return' =>'one'));
    
		 return $info;
        
    }


}




?>